<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>产品列表</title>

    <link href="../../resource/css/bootstrap.min.css?v=3.3.5" rel="stylesheet"
          th:href="@{/resource/css/bootstrap.min.css?v=3.3.5}"/>
    <link href="../../resource/css/font-awesome.min.css?v=4.4.0" rel="stylesheet"
          th:href="@{/resource/css/font-awesome.min.css?v=4.4.0}"/>
    <!-- Morris -->
    <link href="http://cdn.viptool.cn/lib/morris.js/0.4.3/morris.css" rel="stylesheet">
    <link href="../../resource/css/animate.min.css" rel="stylesheet" th:href="@{/resource/css/animate.min.css}"/>
    <link href="../../resource/hotui/css/style.min-1.0.8.css" th:href="@{/resource/hotui/css/style.min-1.0.8.css}"
          rel="stylesheet">
    <link href="../../resource/hotui/css/hotui.style.override.css"
          th:href="@{/resource/hotui/css/hotui.style.override.css}" rel="stylesheet"/>
    <link href="../../resource/hotui/js/plugins/datetimepick/css/daterangepicker.css"
          th:href="@{/resource/hotui/js/plugins/datetimepick/css/daterangepicker.css}" rel="stylesheet"/>

    <style type="text/css">
        .city-picker-selector select {

        }

        .daterangepicker {
            z-index: 999999999 !important;
        }

        .nav-tabs input {
            width: 20px;
            height: 23px;
        }
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight tooltip-demo">
    <!--search-->
    <form role="form" id="searchForm" class="search-panel" method="get" th:object="${condition}">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox">
                    <div class="ibox-content">
                        <div class="form-inline">
                            <input type="hidden" th:value="${pageIndex}" name="pageIndex"/>
                            <div class="form-group m-r-sm">
                                <label class=" control-label" for="keyword">商品名称：</label>
                                <input type="text" class="form-control input-sm mb10" id="keyword"
                                       name="keyword" placeholder="商品名称" style="width: 156px;"/>
                            </div>
                            <a href="javascript:pageHandler.add()"><span class="btn btn-info btn-sm"
                                                                         style="float: right;">添加</span></a>

                            <a href="javascript:pageHandler.addSimple(11)"><span class="btn btn-info btn-sm"
                                                                                 style="float: right;">弹窗添加</span></a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <!--search-->

    <!--list-->
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins m-b-none">
                <div class="tabs-container">
                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="panel-body table-responsive">


                                <table class="table table-bordered table-hover table-center report-table">
                                    <thead>
                                    <tr>
                                        <th></th>
                                        <th>商品名称</th>
                                        <th>直播间</th>
                                        <th>售价</th>
                                        <th>专属</th>
                                        <th>添加时间</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <!--/*@thymesVar id="row" type="com.treasure.mall.biz.entity.product.ProductPO"*/-->
                                    <tr th:each="row,index:${productList}">
                                        <td th:text="${index.index+1}"></td>
                                        <td th:text="${row.productName}"></td>
                                        <td>--</td>
                                        <td th:text="${row.price}">1211</td>
                                        <td>专属</td>
                                        <td th:text="${#temporals.format(row.createTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                                        <td>
                                            <button onclick="pageHandler.edit('123')"
                                                    th:onclick="|pageHandler.edit('${row.productId}')|"
                                                    type="button"
                                                    class="btn btn-white btn-xs m-b-none">编辑
                                            </button>


                                            <button onclick="pageHandler.del('123')"
                                                    th:onclick="|pageHandler.del('${row.productId}')|"
                                                    type="button"
                                                    class="btn btn-xs m-b-none btn-warning">删除
                                            </button>

                                        </td>
                                    </tr>
                                    </tbody>
                                </table>

                                <p style="float: left; margin: 20px 0;">
                                    共<span th:text="${totalRecords}"></span>条记录，当前第<span th:text="${pageIndex}"></span>/<span
                                        th:text="${totalPages==0?1:totalPages}"></span>，每页20条记录
                                </p>
                                <ul style="float: right;" class="pagination pagination-split">
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--基础框架js-->
<script src="../../resource/js/jquery.min.js?v=2.1.4" th:src="@{/resource/js/jquery.min.js?v=2.1.4}"></script>
<script src="../../resource/js/bootstrap.min.js?v=3.3.5" th:src="@{/resource/js/bootstrap.min.js?v=3.3.5}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js?20190316?1234567"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-init.js?20190316(123)}"></script>
<script src="../../resource/hotui/js/content.min.js" th:src="@{/resource/hotui/js/content.min.js}"></script>

<script src="../../resource/lib/moment.min.js" th:src="@{/resource/lib/moment.min.js}"></script>
<script src="../../resource/hotui/js/plugins/datetimepick/js/daterangepicker.js"
        th:src="@{/resource/hotui/js/plugins/datetimepick/js/daterangepicker.js}"></script>


<script type="text/javascript" th:inline="javascript">
    const pageIndex = /*[[${pageIndex}]]*/  1;
    const totalPages = /*[[${totalPages}]]*/  0;
    const pageUri = /*[[@{/product/liveList}]]*/  "";
    const detailUri = /*[[@{/product/detail}]]*/  "";
</script>

<script>
    $(function () {
        //初始化分页
        var pageinate = new hot.paging(".pagination", pageIndex, totalPages, 7);

        pageinate.init(function (p) {
            pageHandler.search(p);
        });
        $(document).keyup(function (event) {
            if (event.keyCode === 13) {
                $(".searchBtn").trigger("click");
            }
        });
    });

    $(function () {
        pageHandler.init();
    });
    var pageHandler = {
        search: function (pageIndex) {
            $("input[name=pageIndex]").val(pageIndex);
            $("#searchForm").submit();
        },
        searchAll: function () {
            window.location.href = pageUri;
        },
        init: function () {
        },
        add: function () {
            window.location.href = 'liveEdit?productId=0';
        },
        addSimple: function (roomId) {
            hot.iframeModal("/product/liveSimpleEdit?productId=0&roomId=" + roomId, '800px', '600px', "直播产品添加");
        },
        editSimple: function (productId) {
            hot.iframeModal("/product/liveSimpleEdit?productId=" + productId, '800px', '600px', "直播产品添加");
        },
        edit: function (id) {
            window.location.href = 'liveEdit?productId=' + id;
        },
        del: function (id) {
            var self = this;
            hot.confirm('删除后将不可恢复，确定删除？', function () {
                hot.ajax("/product/liveDel", {
                    productId: id
                }, function (data) {
                    if (data.success) {
                        layer.msg('删除成功');
                        self.reload();
                    } else {
                        layer.msg("失败：" + data.msg);
                    }
                }, function () {
                }, "post", 100);
            });
        },
        reload: function () {
            $('#searchForm').submit();
        }
    };
</script>
</body>
</html>
